Skip to content

Overlay size option: --overlay2=all:memory,size=1g #11723

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 4, 2025

Conversation

stepancheg
Copy link
Contributor

@stepancheg stepancheg commented May 13, 2025

Implement #11504.

Add optional size= parameter to --overlay2 flag: when it is set, overlay upper layer is mounted with given size flag.

Tested:

sudo bazel-bin/runsc/runsc_/runsc --overlay2=all:memory,size=1m run --bundle ~/bu cont-i

root@:/# dd if=/dev/urandom of=/x bs=1k count=1000
1000+0 records in
1000+0 records out
1024000 bytes (1.0 MB, 1000 KiB) copied, 0.0109061 s, 93.9 MB/s

root@:/# dd if=/dev/urandom of=/x bs=1k count=1100
dd: error writing '/x': No space left on device
1021+0 records in
1020+0 records out
1044480 bytes (1.0 MB, 1020 KiB) copied, 0.011396 s, 91.7 MB/s
  -overlay
        DEPRECATED: use --overlay2=all:memory to achieve the same effect
  -overlay2 value
        wrap mounts with overlayfs. Format is
        * 'none' to turn overlay mode off
        * {mount}:{medium}[size={size}], where
            'mount' can be 'root' or 'all'
            'medium' can be 'memory', 'self' or 'dir=/abs/dir/path' in which filestore will be created
            'size' optional parameter overrides default overlay upper layer size
         (default root:self)
  -panic-log string
        file path where panic reports and other Go's runtime messages are written.

@stepancheg stepancheg force-pushed the overlay-size branch 4 times, most recently from c25a5c4 to 10ff226 Compare May 13, 2025 06:20
@stepancheg stepancheg marked this pull request as ready for review May 13, 2025 06:20
@stepancheg stepancheg changed the title Overlay size option: --overlay2=all:memory:size=1g Overlay size option: --overlay2=all:memory,size=1g May 15, 2025
@stepancheg
Copy link
Contributor Author

Changed syntax from

--overlay2=all:memory:size=1g

to

--overlay2=all:memory,size=1g

@stepancheg stepancheg force-pushed the overlay-size branch 2 times, most recently from 9642db8 to d7cb29a Compare May 15, 2025 20:50
Copy link
Collaborator

@ayushr2 ayushr2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see the discussion in #11504. I'd prefer not to complicate the --overlay2 flag any further. If you really want to use memory backend via --overlay2=*:memory, then consider applying memory limits to the entire container. OR try using the file backend with self medium and setting up size limits on the host rootfs directory.

@stepancheg
Copy link
Contributor Author

(deleted wrong comments; let me think)

@stepancheg
Copy link
Contributor Author

New version where overlay size is passed in GoferMountConf.UpperSize.

@stepancheg stepancheg force-pushed the overlay-size branch 2 times, most recently from 1fff6f9 to 9cd19fd Compare May 21, 2025 15:54
@stepancheg stepancheg requested a review from ayushr2 May 21, 2025 15:56
@stepancheg
Copy link
Contributor Author

Next version ready for review.

@stepancheg
Copy link
Contributor Author

Hello, can I do something to have this PR accepted?

Copy link
Collaborator

@ayushr2 ayushr2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@ayushr2
Copy link
Collaborator

ayushr2 commented May 29, 2025

Also, could you update the docs here:

### Root Filesystem Overlay

I think this is useful and others who want to set disk limits without having to jump all the hoops of reconfiguring their Docker home dir with a different filesystem etc will find such docs useful.

@stepancheg
Copy link
Contributor Author

Done and done.

@stepancheg
Copy link
Contributor Author

Google internal checks FAILED

Can I help with it?

@ayushr2
Copy link
Collaborator

ayushr2 commented Jun 3, 2025

Our presubmits were broken for past few days. Triggering submit again.

copybara-service bot pushed a commit that referenced this pull request Jun 3, 2025
Implement #11504.

Add optional `size=` parameter to `--overlay2` flag: when it is set, overlay upper layer is mounted with given size flag.

Tested:

```
sudo bazel-bin/runsc/runsc_/runsc --overlay2=all:memory,size=1m run --bundle ~/bu cont-i

root@:/# dd if=/dev/urandom of=/x bs=1k count=1000
1000+0 records in
1000+0 records out
1024000 bytes (1.0 MB, 1000 KiB) copied, 0.0109061 s, 93.9 MB/s

root@:/# dd if=/dev/urandom of=/x bs=1k count=1100
dd: error writing '/x': No space left on device
1021+0 records in
1020+0 records out
1044480 bytes (1.0 MB, 1020 KiB) copied, 0.011396 s, 91.7 MB/s
```

```
  -overlay
        DEPRECATED: use --overlay2=all:memory to achieve the same effect
  -overlay2 value
        wrap mounts with overlayfs. Format is
        * 'none' to turn overlay mode off
        * {mount}:{medium}[size={size}], where
            'mount' can be 'root' or 'all'
            'medium' can be 'memory', 'self' or 'dir=/abs/dir/path' in which filestore will be created
            'size' optional parameter overrides default overlay upper layer size
         (default root:self)
  -panic-log string
        file path where panic reports and other Go's runtime messages are written.
```

FUTURE_COPYBARA_INTEGRATE_REVIEW=#11723 from stepancheg:overlay-size 451544b
PiperOrigin-RevId: 764885043
copybara-service bot pushed a commit that referenced this pull request Jun 3, 2025
Implement #11504.

Add optional `size=` parameter to `--overlay2` flag: when it is set, overlay upper layer is mounted with given size flag.

Tested:

```
sudo bazel-bin/runsc/runsc_/runsc --overlay2=all:memory,size=1m run --bundle ~/bu cont-i

root@:/# dd if=/dev/urandom of=/x bs=1k count=1000
1000+0 records in
1000+0 records out
1024000 bytes (1.0 MB, 1000 KiB) copied, 0.0109061 s, 93.9 MB/s

root@:/# dd if=/dev/urandom of=/x bs=1k count=1100
dd: error writing '/x': No space left on device
1021+0 records in
1020+0 records out
1044480 bytes (1.0 MB, 1020 KiB) copied, 0.011396 s, 91.7 MB/s
```

```
  -overlay
        DEPRECATED: use --overlay2=all:memory to achieve the same effect
  -overlay2 value
        wrap mounts with overlayfs. Format is
        * 'none' to turn overlay mode off
        * {mount}:{medium}[size={size}], where
            'mount' can be 'root' or 'all'
            'medium' can be 'memory', 'self' or 'dir=/abs/dir/path' in which filestore will be created
            'size' optional parameter overrides default overlay upper layer size
         (default root:self)
  -panic-log string
        file path where panic reports and other Go's runtime messages are written.
```

FUTURE_COPYBARA_INTEGRATE_REVIEW=#11723 from stepancheg:overlay-size 451544b
PiperOrigin-RevId: 764885043
@stepancheg
Copy link
Contributor Author

Fixed tests, replaced %d with %s.

Sorry I missed the tests: I cannot run every test on my machine

bazel test runsc/...

fails with error I don't understand.

pkg/sentry/socket/plugin/stack/notifier.go:114:21: undefined: cgo.EpollCreate
pkg/sentry/socket/plugin/stack/notifier.go:120:14: undefined: cgo.EpollWait
pkg/sentry/socket/plugin/stack/notifier.go:155:7: undefined: cgo.EpollCtl
pkg/sentry/socket/plugin/stack/notifier.go:158:7: undefined: cgo.EpollCtl
pkg/sentry/socket/plugin/stack/notifier.go:162:7: undefined: cgo.EpollCtl
pkg/sentry/socket/plugin/stack/provider.go:74:16: undefined: cgo.Socket
pkg/sentry/socket/plugin/stack/readwriter.go:61:28: undefined: cgo.Recvmsg
pkg/sentry/socket/plugin/stack/readwriter.go:73:12: undefined: cgo.Read
pkg/sentry/socket/plugin/stack/readwriter.go:75:12: undefined: cgo.Readv
pkg/sentry/socket/plugin/stack/readwriter.go:91:13: undefined: cgo.Sendto
pkg/sentry/socket/plugin/stack/readwriter.go:91:13: too many errors

copybara-service bot pushed a commit that referenced this pull request Jun 3, 2025
Implement #11504.

Add optional `size=` parameter to `--overlay2` flag: when it is set, overlay upper layer is mounted with given size flag.

Tested:

```
sudo bazel-bin/runsc/runsc_/runsc --overlay2=all:memory,size=1m run --bundle ~/bu cont-i

root@:/# dd if=/dev/urandom of=/x bs=1k count=1000
1000+0 records in
1000+0 records out
1024000 bytes (1.0 MB, 1000 KiB) copied, 0.0109061 s, 93.9 MB/s

root@:/# dd if=/dev/urandom of=/x bs=1k count=1100
dd: error writing '/x': No space left on device
1021+0 records in
1020+0 records out
1044480 bytes (1.0 MB, 1020 KiB) copied, 0.011396 s, 91.7 MB/s
```

```
  -overlay
        DEPRECATED: use --overlay2=all:memory to achieve the same effect
  -overlay2 value
        wrap mounts with overlayfs. Format is
        * 'none' to turn overlay mode off
        * {mount}:{medium}[size={size}], where
            'mount' can be 'root' or 'all'
            'medium' can be 'memory', 'self' or 'dir=/abs/dir/path' in which filestore will be created
            'size' optional parameter overrides default overlay upper layer size
         (default root:self)
  -panic-log string
        file path where panic reports and other Go's runtime messages are written.
```

FUTURE_COPYBARA_INTEGRATE_REVIEW=#11723 from stepancheg:overlay-size 451544b
PiperOrigin-RevId: 764885043
copybara-service bot pushed a commit that referenced this pull request Jun 3, 2025
Implement #11504.

Add optional `size=` parameter to `--overlay2` flag: when it is set, overlay upper layer is mounted with given size flag.

Tested:

```
sudo bazel-bin/runsc/runsc_/runsc --overlay2=all:memory,size=1m run --bundle ~/bu cont-i

root@:/# dd if=/dev/urandom of=/x bs=1k count=1000
1000+0 records in
1000+0 records out
1024000 bytes (1.0 MB, 1000 KiB) copied, 0.0109061 s, 93.9 MB/s

root@:/# dd if=/dev/urandom of=/x bs=1k count=1100
dd: error writing '/x': No space left on device
1021+0 records in
1020+0 records out
1044480 bytes (1.0 MB, 1020 KiB) copied, 0.011396 s, 91.7 MB/s
```

```
  -overlay
        DEPRECATED: use --overlay2=all:memory to achieve the same effect
  -overlay2 value
        wrap mounts with overlayfs. Format is
        * 'none' to turn overlay mode off
        * {mount}:{medium}[size={size}], where
            'mount' can be 'root' or 'all'
            'medium' can be 'memory', 'self' or 'dir=/abs/dir/path' in which filestore will be created
            'size' optional parameter overrides default overlay upper layer size
         (default root:self)
  -panic-log string
        file path where panic reports and other Go's runtime messages are written.
```

FUTURE_COPYBARA_INTEGRATE_REVIEW=#11723 from stepancheg:overlay-size 451544b
PiperOrigin-RevId: 764885043
@ayushr2
Copy link
Collaborator

ayushr2 commented Jun 3, 2025

I think you can run tests using make test TARGETS=runsc/config:config_test, it uses bazel from our bazel container.

copybara-service bot pushed a commit that referenced this pull request Jun 3, 2025
Implement #11504.

Add optional `size=` parameter to `--overlay2` flag: when it is set, overlay upper layer is mounted with given size flag.

Tested:

```
sudo bazel-bin/runsc/runsc_/runsc --overlay2=all:memory,size=1m run --bundle ~/bu cont-i

root@:/# dd if=/dev/urandom of=/x bs=1k count=1000
1000+0 records in
1000+0 records out
1024000 bytes (1.0 MB, 1000 KiB) copied, 0.0109061 s, 93.9 MB/s

root@:/# dd if=/dev/urandom of=/x bs=1k count=1100
dd: error writing '/x': No space left on device
1021+0 records in
1020+0 records out
1044480 bytes (1.0 MB, 1020 KiB) copied, 0.011396 s, 91.7 MB/s
```

```
  -overlay
        DEPRECATED: use --overlay2=all:memory to achieve the same effect
  -overlay2 value
        wrap mounts with overlayfs. Format is
        * 'none' to turn overlay mode off
        * {mount}:{medium}[size={size}], where
            'mount' can be 'root' or 'all'
            'medium' can be 'memory', 'self' or 'dir=/abs/dir/path' in which filestore will be created
            'size' optional parameter overrides default overlay upper layer size
         (default root:self)
  -panic-log string
        file path where panic reports and other Go's runtime messages are written.
```

FUTURE_COPYBARA_INTEGRATE_REVIEW=#11723 from stepancheg:overlay-size 32c91c3
PiperOrigin-RevId: 764885043
@stepancheg
Copy link
Contributor Author

runsc/config:config_test

works without container, but if I run in container with make test TARGETS=runsc/..., the error is the same.

Anyway, I will run

bazel test runsc/boot/... runsc/config/... runsc/container/...

for time being.

copybara-service bot pushed a commit that referenced this pull request Jun 3, 2025
Implement #11504.

Add optional `size=` parameter to `--overlay2` flag: when it is set, overlay upper layer is mounted with given size flag.

Tested:

```
sudo bazel-bin/runsc/runsc_/runsc --overlay2=all:memory,size=1m run --bundle ~/bu cont-i

root@:/# dd if=/dev/urandom of=/x bs=1k count=1000
1000+0 records in
1000+0 records out
1024000 bytes (1.0 MB, 1000 KiB) copied, 0.0109061 s, 93.9 MB/s

root@:/# dd if=/dev/urandom of=/x bs=1k count=1100
dd: error writing '/x': No space left on device
1021+0 records in
1020+0 records out
1044480 bytes (1.0 MB, 1020 KiB) copied, 0.011396 s, 91.7 MB/s
```

```
  -overlay
        DEPRECATED: use --overlay2=all:memory to achieve the same effect
  -overlay2 value
        wrap mounts with overlayfs. Format is
        * 'none' to turn overlay mode off
        * {mount}:{medium}[size={size}], where
            'mount' can be 'root' or 'all'
            'medium' can be 'memory', 'self' or 'dir=/abs/dir/path' in which filestore will be created
            'size' optional parameter overrides default overlay upper layer size
         (default root:self)
  -panic-log string
        file path where panic reports and other Go's runtime messages are written.
```

FUTURE_COPYBARA_INTEGRATE_REVIEW=#11723 from stepancheg:overlay-size 32c91c3
PiperOrigin-RevId: 764885043
copybara-service bot pushed a commit that referenced this pull request Jun 4, 2025
Implement #11504.

Add optional `size=` parameter to `--overlay2` flag: when it is set, overlay upper layer is mounted with given size flag.

Tested:

```
sudo bazel-bin/runsc/runsc_/runsc --overlay2=all:memory,size=1m run --bundle ~/bu cont-i

root@:/# dd if=/dev/urandom of=/x bs=1k count=1000
1000+0 records in
1000+0 records out
1024000 bytes (1.0 MB, 1000 KiB) copied, 0.0109061 s, 93.9 MB/s

root@:/# dd if=/dev/urandom of=/x bs=1k count=1100
dd: error writing '/x': No space left on device
1021+0 records in
1020+0 records out
1044480 bytes (1.0 MB, 1020 KiB) copied, 0.011396 s, 91.7 MB/s
```

```
  -overlay
        DEPRECATED: use --overlay2=all:memory to achieve the same effect
  -overlay2 value
        wrap mounts with overlayfs. Format is
        * 'none' to turn overlay mode off
        * {mount}:{medium}[size={size}], where
            'mount' can be 'root' or 'all'
            'medium' can be 'memory', 'self' or 'dir=/abs/dir/path' in which filestore will be created
            'size' optional parameter overrides default overlay upper layer size
         (default root:self)
  -panic-log string
        file path where panic reports and other Go's runtime messages are written.
```

FUTURE_COPYBARA_INTEGRATE_REVIEW=#11723 from stepancheg:overlay-size 32c91c3
PiperOrigin-RevId: 764885043
@copybara-service copybara-service bot merged commit b14059d into google:master Jun 4, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants